﻿using DotNetCommon.Data;
using DotNetCommon.Extensions;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace DBUtil.FastEntity.Builders
{
    public class SelectBuilder<T> where T : class, new()
    {
        public SelectBuilder<T> Where(Expression<Func<T, bool>> expression) => throw new NotImplementedException();
        public SelectBuilder<T> DistinctBy(Expression<Func<T, object>> expression) => throw new NotImplementedException();
        public SelectBuilder<T> OrderBy(Expression<Func<T, object>> expression) => throw new NotImplementedException();
        public SelectBuilder<T> OrderByDesc(Expression<Func<T, object>> expression) => throw new NotImplementedException();
        public SelectBuilder<T> ReSelect(Expression<Func<T, object>> expression) => throw new NotImplementedException();

        public IGroupBuilder<T, T2> GroupBy<T2>(Expression<Func<T, T2>> expression) => throw new NotImplementedException();

        public SelectBuilder<T> Page(int pageIndex, int pageSize) => throw new NotImplementedException();

        //执行
        public string ToSql() => throw new NotImplementedException();

        public T FirstOrDefault() => throw new NotImplementedException();
        public List<T> ToList() => throw new NotImplementedException();

        //先遍历表达式树，找到需要引用的列，然后查询，最后再调用expression返回最后的结果
        public List<Dto> ToList<Dto>(Expression<Func<T, Dto>> expression) => throw new NotImplementedException();
    }

    //T: 原表实体
    //T2: 分组的key
    public interface IGroupBuilder<T, T2> where T : class, new()
    {
        public IGroupBuilder<T, T2> Having(Expression<Func<IGroupFilter<T, T2>, bool>> expression);

        public List<Dto> ToList<Dto>(Expression<Func<IGroupFilter<T, T2>, Dto>> expression) => throw new NotImplementedException();
        public List<Dto> FirstOrDefault<Dto>(Expression<Func<IGroupFilter<T, T2>, Dto>> expression) => throw new NotImplementedException();
    }

    public interface IGroupFilter<T, T2>
    {
        public T2 Key { get; set; }
        public int Count();
    }
}
